/*
 * Powered By [rapid-framework]
 * Web Site: http://www.rapid-framework.org.cn
 * Google Code: http://code.google.com/p/rapid-framework/
 * Since 2008 - 2011
 */

package com.nail.zhaogr.model;

import javax.persistence.*;

import org.hibernate.annotations.GenericGenerator;

import javax.validation.constraints.*;
import org.hibernate.validator.constraints.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import java.util.*;

import javacommon.base.*;
import javacommon.util.*;

import cn.org.rapid_framework.util.*;
import cn.org.rapid_framework.web.util.*;
import cn.org.rapid_framework.page.*;
import cn.org.rapid_framework.page.impl.*;

import com.nail.zhaogr.model.*;
import com.nail.zhaogr.dao.*;
import com.nail.zhaogr.service.*;
import com.nail.zhaogr.vo.query.*;

/**
 * @author badqiu email:badqiu(a)gmail.com
 * @version 1.0
 * @since 1.0
 */


@Entity
@Table(name = "rights")
public class Rights extends BaseEntity implements java.io.Serializable{
	private static final long serialVersionUID = 5454155825314635342L;
	
	//alias
	public static final String TABLE_ALIAS = "Rights";
	public static final String ALIAS_RIGHT_ID = "rightId";
	public static final String ALIAS_PARENT_ID = "parentId";
	public static final String ALIAS_RIGHT_NAME = "rightName";
	public static final String ALIAS_RIGHT_CODE = "rightCode";
	public static final String ALIAS_PARENT_CODE = "parentCode";
	public static final String ALIAS_RIGHT_TYPE = "rightType";
	public static final String ALIAS_RIGHT_STATUS = "rightStatus";
	
	//date formats
	

	//可以直接使用: @Length(max=50,message="用户名长度不能大于50")显示错误消息
	//columns START
    /**
     * rightId       db_column: rightId 
     */ 	
	
	private java.lang.Long rightId;
    /**
     * parentId       db_column: parentId 
     */ 	
	
	private java.lang.Long parentId;
    /**
     * rightName       db_column: rightName 
     */ 	
	@Length(max=255)
	private java.lang.String rightName;
    /**
     * rightCode       db_column: rightCode 
     */ 	
	@Length(max=255)
	private java.lang.String rightCode;
    /**
     * parentCode       db_column: parentCode 
     */ 	
	@Length(max=255)
	private java.lang.String parentCode;
    /**
     * rightType       db_column: rightType 
     */ 	
	@Length(max=20)
	private java.lang.String rightType;
    /**
     * rightStatus       db_column: rightStatus 
     */ 	
	
	private java.lang.Integer rightStatus;
	//columns END


	public Rights(){
	}

	public Rights(
		java.lang.Long rightId
	){
		this.rightId = rightId;
	}

	

	public void setRightId(java.lang.Long value) {
		this.rightId = value;
	}
	
	@Id @GeneratedValue(generator="custom-id")
	@GenericGenerator(name="custom-id", strategy = "increment")
	@Column(name = "rightId", unique = true, nullable = false, insertable = true, updatable = true, length = 19)
	public java.lang.Long getRightId() {
		return this.rightId;
	}
	
	@Column(name = "parentId", unique = false, nullable = true, insertable = true, updatable = true, length = 19)
	public java.lang.Long getParentId() {
		return this.parentId;
	}
	
	public void setParentId(java.lang.Long value) {
		this.parentId = value;
	}
	
	@Column(name = "rightName", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getRightName() {
		return this.rightName;
	}
	
	public void setRightName(java.lang.String value) {
		this.rightName = value;
	}
	
	@Column(name = "rightCode", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getRightCode() {
		return this.rightCode;
	}
	
	public void setRightCode(java.lang.String value) {
		this.rightCode = value;
	}
	
	@Column(name = "parentCode", unique = false, nullable = true, insertable = true, updatable = true, length = 255)
	public java.lang.String getParentCode() {
		return this.parentCode;
	}
	
	public void setParentCode(java.lang.String value) {
		this.parentCode = value;
	}
	
	@Column(name = "rightType", unique = false, nullable = true, insertable = true, updatable = true, length = 20)
	public java.lang.String getRightType() {
		return this.rightType;
	}
	
	public void setRightType(java.lang.String value) {
		this.rightType = value;
	}
	
	@Column(name = "rightStatus", unique = false, nullable = true, insertable = true, updatable = true, length = 10)
	public java.lang.Integer getRightStatus() {
		return this.rightStatus;
	}
	
	public void setRightStatus(java.lang.Integer value) {
		this.rightStatus = value;
	}
	
	
	private Set rightss = new HashSet(0);
	public void setRightss(Set<Rights> rights){
		this.rightss = rights;
	}
	
	@OneToMany(cascade = { CascadeType.MERGE }, fetch = FetchType.LAZY, mappedBy = "rights")
	public Set<Rights> getRightss() {
		return rightss;
	}
	
	private Rights rights;
	public void setRights(Rights rights){
		this.rights = rights;
	}
	
	@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
	@JoinColumns({
		@JoinColumn(name = "parentId",nullable = false, insertable = false, updatable = false) 
	})
	public Rights getRights() {
		return rights;
	}

	public String toString() {
		return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
			.append("RightId",getRightId())
			.append("ParentId",getParentId())
			.append("RightName",getRightName())
			.append("RightCode",getRightCode())
			.append("ParentCode",getParentCode())
			.append("RightType",getRightType())
			.append("RightStatus",getRightStatus())
			.toString();
	}
	
	public int hashCode() {
		return new HashCodeBuilder()
			.append(getRightId())
			.toHashCode();
	}
	
	public boolean equals(Object obj) {
		if(obj instanceof Rights == false) return false;
		if(this == obj) return true;
		Rights other = (Rights)obj;
		return new EqualsBuilder()
			.append(getRightId(),other.getRightId())
			.isEquals();
	}
}

